<?php
/**
 * Short Description  
 *
 * Long Description 
 *
 * @category   
 * @package    
 * @subpackage 
 * @copyright 
 * @author     Sandeep Manne<sandeep.manne@costrategix.com>
 */

require_once 'default/controllers/CoreController.php';

class Social_IndexController extends CoreController
{
	public function linkedinFriendsAction()
	{
		require_once "Core/Social/Adapter/Linkedin.php";
		$config = App::getModuleConfig("social", true);
		$linkedin = new Core_Social_Adapter_Linkedin($config['linkedin']);
		if (!$linkedin->hasAccess()){
			$referer = new Zend_Session_Namespace('Http_Referer');
            $referer->redirect = $this->getRequest()->getRequestUri();
			$this->_redirect('/social/index/linkedin-auth');
		}
		var_dump(Zend_Auth::getInstance()->getIdentity());
		var_dump($linkedin->getFriends());exit;
	}
	
	public function linkedinAuthAction()
	{
		require_once "Core/Social/Adapter/Linkedin.php";
		$config = App::getModuleConfig("social", true);
		$linkedin = new Core_Social_Adapter_Linkedin($config['linkedin']);
		if (count($this->getRequest()->getParams()) > 3) {
			$linkedin->getAccessToken($this->getRequest()->getParams());
			$referer = new Zend_Session_Namespace('Http_Referer');
			$this->_redirect($referer->redirect);
		}
		$linkedin->getRequestToken();
	}
	
}